/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.rcs.filesystem;

import java.io.File;
import org.rcs.folders.VirtualItem;
import org.rcs.folders.VirtualItemsSytem;

/**
 *
 * @author ruben
 */
public class FileItemsSystem implements VirtualItemsSytem {

  private File rootFile ;

  public FileItemsSystem(File rootFile) {
    this.rootFile = rootFile;
  }

  @Override
  public VirtualItem getVirtualItem(String uri) {
    File resourceFile = new File(rootFile, uri);

    if (resourceFile.exists())
      if (resourceFile.isDirectory())
        return new FolderItem(resourceFile);
      else
        return new FileItem(resourceFile);
    else
      return null;
  }
}